﻿using Caliburn.Micro;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace UrTransPayload
{
    //如果好用，请收藏地址，帮忙分享。
    public class Control
    {
        /// <summary>
        /// 
        /// </summary>
        public string serverAddr { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string slaveStatus { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string masterStatus { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string disconnectMaster { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string force { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string position { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string taskCommand { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string taskResult { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string masterRealtimeData { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string slaveRealtimeData { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string virtualFence { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string masterCommand { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string protectedParameters { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string activeProbeName { get; set; }
    }

    public class Configure
    {
        /// <summary>
        /// 
        /// </summary>
        public string serverAddr { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string status { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string deviceControl { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string connectMaster { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string updateLocalConfigure { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string taskCommand { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string taskResult { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string masterRealtimeData { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string slaveRealtimeData { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string visionStatus { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string visionTaskCommand { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string visionTaskResult { get; set; }
    }

    public class Network
    {
        /// <summary>
        /// 
        /// </summary>
        public Control control { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public Configure configure { get; set; }
    }

    public class Camera
    {
        /// <summary>
        /// 
        /// </summary>
        public string type { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string colorResolution { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int colorFrameRate { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string depthResolution { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int depthFrameRate { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string alignType { get; set; }
    }

    public class WorkSpaceItem
    {
        /// <summary>
        /// 
        /// </summary>
        public int id { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string type { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string space { get; set; }
    }

    [DataContract]
    public class ProbeListItem : PropertyChangedBase
    {
        private int m_id;
        [DataMember]
        public int id 
        {
            get { return m_id; }
            set
            {
                m_id = value;
                NotifyOfPropertyChange(() => id);
            }
        }

        private string m_name;
        [DataMember]
        public string name
        {
            get { return m_name; }
            set
            {
                m_name = value;
                NotifyOfPropertyChange(() => name);
            }
        }

        private string m_TCP= "0.0 0.0 0.0 0.0 0.0 0.0";
        [DataMember]
        public string TCP
        {
            get { return m_TCP; }
            set
            {
                m_TCP = value;
                NotifyOfPropertyChange(() => TCP);
            }
        }

        private double m_payload;
        [DataMember]
        public double payload
        {
            get { return m_payload; }
            set
            {
                m_payload = value;
                NotifyOfPropertyChange(() => payload);
            }
        }

        private string m_gravityCenter= "0.0 0.0 0.0";
        [DataMember]
        public string gravityCenter
        {
            get { return m_gravityCenter; }
            set
            {
                m_gravityCenter = value;
                NotifyOfPropertyChange(() => gravityCenter);
            }
        }
    }

    [DataContract]
    public class Robot : PropertyChangedBase
    {
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public string localEthernet { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public string localBridgeEthernet { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public int localPort { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public string robotIP { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public string initPos { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public string initJoints { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public List<WorkSpaceItem> workSpace { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public int activeProbeId { get; set; }

        private ObservableCollection<ProbeListItem> m_probeList;
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public ObservableCollection<ProbeListItem> probeList
        {
            get { return m_probeList; }
            set
            {
                m_probeList = value;
                NotifyOfPropertyChange(() => probeList);
            }
        }
    }

    [DataContract]
    public class Device : PropertyChangedBase
    {
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public Camera camera { get; set; }
        public Robot m_robot;
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public Robot robot
        {
            get { return m_robot; }
            set
            {
                m_robot = value;
                NotifyOfPropertyChange(() => robot);
            }
        }
    }

    public class TemplateItem
    {
        /// <summary>
        /// 
        /// </summary>
        public int id { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string src { get; set; }
    }

    public class UnitsItem
    {
        /// <summary>
        /// 
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string type { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string snapshotPos { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double moveInterval { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double rotationAngle { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int targetId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public bool isCalibrated { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string transformationMatrix { get; set; }
    }

    public class Calibration
    {
        /// <summary>
        /// 
        /// </summary>
        public List<TemplateItem> template { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public List<UnitsItem> units { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string activeUnit { get; set; }
    }

    public class ProtectedParameters
    {
        /// <summary>
        /// 
        /// </summary>
        public int forceLimit { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int contactForce { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int sensitivity { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int sensitivityLimit { get; set; }
    }

    public class Local
    {
        /// <summary>
        /// 
        /// </summary>
        public Device device { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public Calibration calibration { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public ProtectedParameters protectedParameters { get; set; }
    }


    [DataContract]
    public class RobotCfg : PropertyChangedBase
    {
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public string license { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public string volumePath { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public Network network { get; set; }
        public Local m_local;
        /// <summary>
        /// 
        /// </summary>
        [DataMember]
        public Local local
        {
            get { return m_local; }
            set
            {
                m_local = value;
                NotifyOfPropertyChange(() => local);
            }
        }
    }

}
